#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
    btn=new QPushButton(this);
    frame=new QFrame(this);
    frame->setFrameShape(QFrame::Box);
    frame->setAutoFillBackground(true);
    frame->setFrameShadow(QFrame::Raised);
    btn->setText("调用颜色对话框");
    layout=new QGridLayout(this);
    layout->addWidget(btn,0,0);
    layout->addWidget(frame,1,0);

    connect(btn,&QPushButton::clicked,this,&Dialog::setColorSlot);
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::setColorSlot()
{
   QColor color= QColorDialog::getColor();

   if(color.isValid())
   {
       frame->setPalette(QPalette(color));
   }
}

void Dialog::showColorSlot()
{

}

